//力智算法
function lz(oldNum, addNum, type) {
	if(jsonData.blz) {
		addNum *= (1 + jsonData.blz.oldNum);
	}
	var a1 = (oldNum + addNum) / 250 + 1;
	var a2 = oldNum / 250 + 1;
	return a1 / a2 - 1;
}

//攻击力算法
function gj(oldNum, addNum, type) {
	var lzNum = jsonData.lz.oldNum + jsonData.lz[type];
	var xishu = jsonData.lz.ratio;
	var coefficient = lzNum / 250 + 1
	if(jsonData.bsg) {
		addNum *= (1 + jsonData.bsg.oldNum);
	}
	var a1 = addNum * coefficient;
	return a1 / (oldNum * (1 + xishu));
}

//独立算法
function dl(oldNum, addNum, type) {
	if(jsonData.bsg) {
		addNum *= (1 + jsonData.bsg.oldNum);
	}
	return(oldNum + addNum) / oldNum - 1;
}

//属强算法
function sq(oldNum, addNum, type) {
	//隐藏属强
	oldNum += 100 / 9;
	var a1 = (oldNum + addNum) / (2000 / 9) + 1;
	var a2 = oldNum / (2000 / 9) + 1;
	return a1 / a2 - 1;
}

//暴击率算法
function bj(oldNum, addNum, type) {
	oldNum += 3;
	oldNum = oldNum > 100 ? 100 : oldNum;
	var sum = oldNum + addNum;
	sum = sum > 100 ? 100 : sum;
	var a1 = sum / 200 + 1;
	var a2 = oldNum / 200 + 1;
	return a1 / a2 - 1;
}

//白字算法
function bz(oldNum, addNum, type) {
	//获取属性白字
	if(jsonData.sb != undefined) {
		var sb = jsonData.sb.oldNum + jsonData.sb[type];
		var sqNum = jsonData.sq.oldNum + jsonData.sq[type] + 100 / 9;
		oldNum += (sqNum / 220 * sb) + sb;
	}
	var a1 = (oldNum + addNum) / 100 + 1;
	var a2 = oldNum / 100 + 1;
	return a1 / a2 - 1;

}

//白字破招额外提升率算法
function bp(oldNum, addNum, type) {

	//总白字
	oldNum = 0;
	//属性白字
	addNum = 0;

	//获取总白字
	if(jsonData.bz != undefined) {
		oldNum = jsonData.bz.oldNum + jsonData.bz[type];
	}

	//获取属性白字
	if(jsonData.sb != undefined) {
		addNum = jsonData.sb.oldNum + jsonData.sb[type];
		var sqNum = jsonData.sq.oldNum + jsonData.sq[type] + 100 / 9;
		oldNum += addNum + (sqNum / 220 * addNum);
	}

	var a1 = 1 / 16 * (9 - 5 / (oldNum / 100 + 1)) + 1;
	return a1 / 1.25 - 1;
}

//属性白字提升率算法
function sb(oldNum, addNum, type) {

	//属强
	var sqNum = 100 / 9;
	
	if(jsonData.sq){
		sqNum += jsonData.sq.oldNum + jsonData.sq[type];
	}

	//属性白字换算
	oldNum = (sqNum / 220 * oldNum) + oldNum;

	//获取总白字
	if(jsonData.bz != undefined) {
		oldNum += jsonData.bz.oldNum + jsonData.bz[type];
	}

	addNum = addNum + (sqNum / 220 * addNum);
	var a1 = (oldNum + addNum) / 100 + 1;
	var a2 = oldNum / 100 + 1;
	return a1 / a2 - 1;
}

//爆伤算法
function bs(oldNum, addNum, type) {
	var bjRatio = 1;
	if(jsonData.bj) {
		bjRatio = (jsonData.bj.oldNum + jsonData.bj[type]) / 100;
	}
	var sum = oldNum + addNum;
	var a1 = bjRatio * sum / 100 + 1;
	var a2 = bjRatio * oldNum / 100 + 1;
	return a1 / a2 - 1;
}

//技能攻击力算法
function jg(oldNum, addNum, type) {
	return addNum / 100;
}

//百分比力量提升率算法
function blz(oldNum, addNum, type) {
	var lzNum = jsonData.lz.oldNum + jsonData.lz[type];

	var a1 = (lzNum * addNum / 100) / (lzNum + 250);
	var a2 = lzNum * oldNum / 100;
	var a3 = a2 / (lzNum - a2 + 250) + 1;

	return a1 / a3;
}

//通用加成
function universal(oldNum, addNum, type) {
	var a1 = (oldNum + addNum) / 100 + 1;
	var a2 = oldNum / 100 + 1;
	return a1 / a2 - 1;
}

var hz, sg, bsg;

hz = sg = bsg = universal;